package com.kylin.artwork.openapi.starter.config;

import com.kylin.domain.oauth2.social.wechat.WxPayProperties;
import com.lly835.bestpay.config.WxPayConfig;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 支付配置
 * @author Damon S.
 * @version v1.0.1
 * @date 2021年01月24日 16:22
 */
@Configuration
@RequiredArgsConstructor
public class KylinPayConfigure {

    private final WxPayProperties wxPayProperties;

    @Bean
    public BestPayServiceImpl bestPayService() {
        WxPayConfig wxPayConfig = new WxPayConfig();
        wxPayConfig.setAppId(wxPayProperties.getMpAppId());
        wxPayConfig.setMiniAppId(wxPayProperties.getMiniAppId());
        wxPayConfig.setMchId(wxPayProperties.getMchId());
        wxPayConfig.setMchKey(wxPayProperties.getMchKey());
        wxPayConfig.setKeyPath(wxPayProperties.getKeyPath());
        wxPayConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
        wxPayConfig.setAppAppId(wxPayProperties.getAppAppId());

        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        bestPayService.setWxPayConfig(wxPayConfig);
        return bestPayService;
    }
}
